@extends('app')

@section('content')
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="tabbable" id="tabs-876069">
                <ul class="nav nav-tabs">
                   <li class="active">
                        <a href="#panel-656128" data-toggle="tab">回答列表</a>
                    </li>
                </ul>
                <div class="panel panel-default tab-pane mt20" id="panel-952476">
                    <div class="main">
                        <div style="width: 50%;float: left;">
                            <form class="form-horizontal" action="/admin/bbs/answers/index" method="get">
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-2 control-label">关键词:</label>
                                    <div class="col-sm-10">
                                        <input type="text" name="keywords" class="form-control" id="inputEmail3" placeholder="输入关键词">
                                    </div>
                                </div>

                                {!! csrf_field() !!}
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button type="submit" class="btn btn-primary">搜索</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
                <div class="tab-content">
                    <!--列表开始-->
                    <div class="tab-pane active" id="panel-656128">
                        <div class="panel panel-default mt20">

                        <div class="table-responsive panel-body">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th><input type="checkbox" name="checkAll" value=""></th>
                                    <th>问题标题</th>
                                    <th>回答内容</th>
                                    {{--<th>支持</th>
                                    <th>反对</th>--}}
                                    <th>评论数</th>
                                    {{--<th>感谢</th>--}}
                                    <th>用户</th>
                                    <th>发布时间</th>
                                    <th>最后更新</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($answers as $res)
                                <tr id="news_{{ $res->id }}">
                                    <td><input type="checkbox" name="answers" value="{{ $res->id }}"></td>
                                    <td><a href="{{ url('/bbs/'.$res->question_id)}} ">{{ count($res->question)>0?str_limit($res->question->title,20):'文章已删除'}}</a></td>
                                    <td><a href="javascript:void(0)"  onclick="showComment('{{$res->title}}')">{{ str_limit($res->title,20)}}</a></td>
                                    {{--<td>{{ $res->agree_count }}</td>
                                    <td>{{ $res->against_count }}</td>--}}
                                    <td>{{ $res->comment_count }}</td>
                                    {{--<td>{{ $res->thanks_count }}</td>--}}
                                    <td>{{getUserName($res->user_id)}}</td>
                                    <td>{{ $res->created_at }}</td>
                                    <td>{{ $res->updated_at }}</td>
                                    <td>
                                        <a href="javascript:void(0);" onclick="del_one('/admin/bbs/answers/delete','{{$res->id}}','{{ csrf_token() }}','answer_id')"><i class="glyphicon glyphicon-remove-sign"></i></a>
                                    </td>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                        </div>
                         <div>
                            <a class="btn btn-danger" onclick="batch_del('/admin/bbs/answers/deletes','{{ csrf_token() }}', 'id', 'answers'); ">删除</a>
                        </div>
                        <div>{!! $answers->render() !!} </div>
                    </div>
                    <!--列表结束-->
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
$('input').iCheck({
	checkboxClass: 'icheckbox_flat-blue',
    radioClass: 'iradio_flat-blue',
    increaseArea: '-10' // optional
});
//处理全选函数
$('input[name=checkAll]').on('ifChecked', function(event){
	$('input:checkbox').iCheck('check');
});
$('input[name=checkAll]').on('ifUnchecked', function(event){
	$('input:checkbox').iCheck('uncheck');
});
    function selectCourse(id,url,token)
    {
        $.ajax({
            'url':url,
            'type':'POST',
            'data':"id="+id+'&_token='+token,
            success: function(data){
                if(data.status == 'success'){
                    result = data.data;
                    option = '<option value="0">--无--</option>';
                    $.each(result, function(k,e){
                        option += '<option value="'+e.id+'">'+e.name+'</option>';
                    });
                    $("#course").html(option);
                }

            }
        });
    }


    $('.form_datetime').datetimepicker({
        format:'yyyy-mm-dd',
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0
    });
</script>

@endsection
